from django.contrib import admin
from .models import Area, Cinema


@admin.register(Area)
class AreaAdmin(admin.ModelAdmin):
    """城市区域管理"""
    list_display = ['area_id', 'area_name', 'area_type', 'parent_id', 'hot', 'sort', 'pinyin']
    list_filter = ['area_type', 'hot', 'parent_id']
    search_fields = ['area_name', 'pinyin']
    list_editable = ['hot', 'sort']
    ordering = ['-hot', 'sort', 'area_id']

    fieldsets = (
        ('基本信息', {
            'fields': ('area_id', 'area_name', 'area_type', 'pinyin')
        }),
        ('层级关系', {
            'fields': ('parent_id', 'son_id')
        }),
        ('其他设置', {
            'fields': ('agency_id', 'sort', 'hot')
        }),
    )


@admin.register(Cinema)
class CinemaAdmin(admin.ModelAdmin):
    """影院管理"""
    list_display = ['store_id', 'title', 'area_id', 'avg_price', 'state', 'sort', 'seat']
    list_filter = ['state', 'area_id', 'type']
    search_fields = ['title', 'address']
    list_editable = ['state', 'sort']
    ordering = ['-sort', '-store_id']

    fieldsets = (
        ('基本信息', {
            'fields': ('store_id', 'title', 'type', 'cat_id', 'area_id')
        }),
        ('图片信息', {
            'fields': ('img', 'imgs')
        }),
        ('影院座位数据', {
            'fields': ('seat',)
        }),
        ('联系信息', {
            'fields': ('address', 'tel', 'work_time', 'lat', 'lng')
        }),
        ('价格信息', {
            'fields': ('start_price', 'send_price', 'avg_price')
        }),
        ('统计信息', {
            'fields': ('comment_count', 'comment_bad_count', 'comment_good_count', 'sell_count')
        }),
        ('其他设置', {
            'fields': ('sort', 'state', 'description')
        }),
    )
